package cn.iocoder.yudao.module.member.api.studentCurriculumVitae;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.api.studentCurriculumVitae.dto.StudentCurriculumVitaeCreateReqDTO;
import cn.iocoder.yudao.module.member.api.studentCurriculumVitae.dto.StudentCurriculumVitaePageReqDTO;
import cn.iocoder.yudao.module.member.api.studentCurriculumVitae.dto.StudentCurriculumVitaeRespDTO;
import cn.iocoder.yudao.module.member.api.studentCurriculumVitae.dto.StudentCurriculumVitaeUpdateReqDTO;
import cn.iocoder.yudao.module.member.controller.admin.studentCurriculumVitae.vo.StudentCurriculumVitaeCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.studentCurriculumVitae.vo.StudentCurriculumVitaePageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.studentCurriculumVitae.vo.StudentCurriculumVitaeUpdateReqVO;
import cn.iocoder.yudao.module.member.convert.studentCurriculumVitae.StudentCurriculumVitaeConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.studentCurriculumVitae.StudentCurriculumVitaeDO;
import cn.iocoder.yudao.module.member.service.studentCurriculumVitae.StudentCurriculumVitaeService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Service
@Validated
public class StudentCurriculumVitaeApiImpl implements StudentCurriculumVitaeApi{

    @Resource
    private StudentCurriculumVitaeService studentCurriculumVitaeService;



    @Override
    public Long createStudentCurriculumVitae(StudentCurriculumVitaeCreateReqDTO createReqDTO) {
        StudentCurriculumVitaeCreateReqVO studentCurriculumVitaeCreateReqVO=new StudentCurriculumVitaeCreateReqVO();
        BeanUtils.copyProperties(createReqDTO,studentCurriculumVitaeCreateReqVO);
        return studentCurriculumVitaeService.createStudentCurriculumVitae(studentCurriculumVitaeCreateReqVO);
    }

    @Override
    public Boolean updateStudentCurriculumVitae(StudentCurriculumVitaeUpdateReqDTO updateReqDTO) {
        StudentCurriculumVitaeUpdateReqVO studentCurriculumVitaeUpdateReqVO=new StudentCurriculumVitaeUpdateReqVO();
        BeanUtils.copyProperties(updateReqDTO,studentCurriculumVitaeUpdateReqVO);
        studentCurriculumVitaeService.updateStudentCurriculumVitae(studentCurriculumVitaeUpdateReqVO);
        return true;
    }

    @Override
    public Boolean updateByStudentId(StudentCurriculumVitaeUpdateReqDTO updateReqDTO) {
        StudentCurriculumVitaeUpdateReqVO studentCurriculumVitaeUpdateReqVO=new StudentCurriculumVitaeUpdateReqVO();
        BeanUtils.copyProperties(updateReqDTO,studentCurriculumVitaeUpdateReqVO);
        studentCurriculumVitaeService.updateByStudentId(studentCurriculumVitaeUpdateReqVO);
        return true;
    }


    @Override
    public Boolean deleteStudentCurriculumVitae(@RequestParam("id") Long id) {
        studentCurriculumVitaeService.deleteStudentCurriculumVitae(id);
        return true;
    }

    @Override
    public List<StudentCurriculumVitaeRespDTO> getStudentCurriculumVitaeByStudentId(Long studentId) {
        List<StudentCurriculumVitaeDO> studentCurriculumVitaeDO=studentCurriculumVitaeService.getStudentCurriculumVitaeByStudentId(studentId);
        return StudentCurriculumVitaeConvert.INSTANCE.convertList1(studentCurriculumVitaeDO);
    }

    @Override
   public StudentCurriculumVitaeRespDTO getStudentCurriculumVitae(@RequestParam("id") Long id) {
        StudentCurriculumVitaeDO studentCurriculumVitae = studentCurriculumVitaeService.getStudentCurriculumVitae(id);
        return StudentCurriculumVitaeConvert.INSTANCE.convert1(studentCurriculumVitae);
    }

    @Override
    public PageResult<StudentCurriculumVitaeRespDTO> getStudentCurriculumVitaePage(StudentCurriculumVitaePageReqDTO pageVO) {
        StudentCurriculumVitaePageReqVO studentCurriculumVitaePageReqVO=new StudentCurriculumVitaePageReqVO();
        BeanUtils.copyProperties(pageVO,studentCurriculumVitaePageReqVO);
        PageResult<StudentCurriculumVitaeDO> pageResult = studentCurriculumVitaeService.getStudentCurriculumVitaePage(studentCurriculumVitaePageReqVO);
        return StudentCurriculumVitaeConvert.INSTANCE.convertPage1(pageResult);
    }


    @Override
    public StudentCurriculumVitaeRespDTO getStudentInfoByMobile(Long projectId, String mobile) {
        return studentCurriculumVitaeService.getStudentInfoByMobile(projectId,mobile);
    }
}
